package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.example.entity.Account;
import com.example.service.BankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @Author ZHAO Yudong
 * @Date 2021/12/7 15:42
 * @description：
 */
@RestController
@RequestMapping("/bank")
public class BankController {

    @Autowired
    private BankService bankService;

    @GetMapping("/selectAll")
    public List<Account> selectAll(){
        return bankService.selectAll();
    }

    @GetMapping("/transMoney")
    public Integer transMoney(@RequestParam Integer money){
        int add = bankService.add(money);
        return add;
    }

    @PostMapping("/upload")
    public String upload(@RequestParam MultipartFile file){
        String originalFilename = file.getOriginalFilename();
        System.out.println("fileName="+originalFilename);
        return originalFilename;
    }

    @PostMapping("/aa")
    public Map<String,Object> fun(@RequestBody Map<String,Object> map){
        System.out.println(JSON.toJSON(map));
        return map;
    }


}
